package com.shop.item.api.service.impl;

import com.shop.common.entity.item.Category;
import com.shop.common.model.InputBean;
import com.shop.common.model.ServiceBean;
import com.shop.common.tmpl.BaseService;
import com.shop.item.atom.dao.CategoryMapper;
import com.shop.item.api.service.IICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl extends BaseService implements IICategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public ServiceBean<List<Category>> getCategoryList() {
        List<Category> list = categoryMapper.getCategoryList();
        return resultModel(true, "", list);
    }

    @Override
    public ServiceBean<String> addCategory(InputBean<Category> inputBean) {
        int num = categoryMapper.insert(inputBean.getParam());
        if (opSuccess(num)) {
            return resultSuccess("");
        }
        return resultFailed("");
    }
}
